package com.heima.controller;

import com.heima.pojo.Business;
import com.heima.pojo.Node;
import com.heima.pojo.VendingMachine;
import com.heima.service.NodeService;
import com.heima.service.RegionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("api/vm-service")
@Slf4j
@RestController
@Api(value = "点位管理")
public class NodeController {
    @Autowired
    private NodeService nodeService;
    @Autowired
    private RegionService regionService;

    @GetMapping("/businessType")
    @ApiOperation("商圈查询")
    public List<Business> getBussinessList(){
        log.info("商圈查询");
        return nodeService.selectBusinessList();
    }

    @PostMapping("/node")
    @ApiOperation("更新点位")
    public boolean insertNode(@RequestBody Node node){
        log.info("要添加的node点位为：{}",node);
        return nodeService.insertNode(node);
    }

    @ApiOperation("查询node详情信息")
    @GetMapping("/node/vmList/{nodeId}")
    public List<VendingMachine> selectBigList(@PathVariable String nodeId){
        List<VendingMachine> list = nodeService.selectBigList(nodeId);
        return list;
    }
    @ApiOperation("修改点位")
    @PutMapping("/node/{nodeId}")
    public Boolean updateNode(@PathVariable String nodeId , @RequestBody Node node){
        return nodeService.updateNode(nodeId,node);
    }

    @ApiOperation("删除node")
    @DeleteMapping("/node/{nodeId}")
    public Boolean deleteNode(@PathVariable String nodeId){
        return nodeService.deleteNode(nodeId);
    }

}
